<!--
 * @Description: 
 * @Author: shilinzhou
 * @Date: 2024-02-02 10:18:45
 * @LastEditors: James324
 * @LastEditTime: 2024-03-22 09:27:28
-->
<script setup lang="ts">
import { tableConfig } from './config/table-config';
import { searchConfig } from './config/search-config';
import { doGetSelfControlList } from '@/api/demand/schedule-detail/index';
import { ProcessRecord } from '@/api/demand/schedule-detail/model/type';

const router = useRouter();
const route = useRoute();

const tableRef = ref<TableRef>();

const searchRef = ref<SearchRef>();

/**
 * @: 跳转到工序明细
 */
const jumpToDetail = (row: ProcessRecord) => {
    router.push({
        path: '/arithmetic/processDetail',
        query: {
            orderNumber: row.orderNumber,
            materialCode: row.materialCode,
            materialName: row.materialName
        }
    });
    console.log(row, 'row');
};

const state = reactive({
    productionType: '自制',
    orderNumber: route.query.orderNumber as string
});

onActivated(() => {
    state.orderNumber = route.query.orderNumber as string;
});
</script>

<template>
    <q-page>
        <base-search ref="searchRef" :table-ref="tableRef" :searchConfig="searchConfig" />

        <base-table
            ref="tableRef"
            :key="state.orderNumber"
            :tableConfig="tableConfig"
            :getDataFn="doGetSelfControlList"
            :added-params="state"
            :hide-del="true"
            :close-edit="true"
        >
            <!-- 操作项 -->
            <template #action="{ row }">
                <el-link
                    :disabled="row.schedulingStatus === '无需生产'"
                    type="primary"
                    @click="jumpToDetail(row)"
                >
                    工序明细
                </el-link>
            </template>
        </base-table>
    </q-page>
</template>

<style scoped lang="scss"></style>
